import { menuList } from "@/request/api"

// 封装一个state接口
interface menuState {
    menulist: Array<object>
}

const state = {
    menulist: []
}

const getters = {
    getMenuList(state: menuState) {
        return state.menulist
    }
}

const mutations = {
    REQ_MENULIST(state: menuState, payload: any) {
        state.menulist = payload
    }
}

const actions = {
    MenuListActions(context: any) {
        menuList()
            .then((res: any) => {
                console.log(res, '菜单列表');
                if (res.code == 200) {
                    context.commit('REQ_MENULIST', res.list)
                }
            })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}